<?php
session_start();

header('Content-Type: text/plain; charset=utf-8'); 

require("../fantasmatakia/pektis.php");
require("../lib/standard.php");

$globals->check_pektis();

mysqli_autocommit($globals->db, FALSE);
$n = 0;

$query = "UPDATE `partida` SET `pektis1` = NULL WHERE `pektis1` LIKE '" .
	$globals->pektis->login . "'";
@mysqli_query($globals->db, $query);
$n += mysqli_affected_rows($globals->db);

$query = "UPDATE `partida` SET `pektis2` = NULL WHERE `pektis2` LIKE '" .
	$globals->pektis->login . "'";
@mysqli_query($globals->db, $query);
$n += mysqli_affected_rows($globals->db);

if ($n < 1) {
	mysqli_rollback($globals->db);
	die("Δεν βρέθηκε τραπέζι");
}

$query = "DELETE FROM `partida` WHERE (`pektis1` IS NULL) AND (`pektis2` IS NULL)";
@mysqli_query($globals->db, $query);

mysqli_commit($globals->db);
?>
